<!DOCTYPE HTML>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/summernote/summernote.css}" rel="stylesheet" />
<link th:href="@{/ajax/libs/summernote/summernote-bs3.css}"
	rel="stylesheet" />
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-jobinfo-edit"
			th:object="${jobInfo}">
			<input id="id" name="id" th:field="*{id}" type="hidden">
			<div class="col-md-6">
				<div class="form-group">
					<label class="col-sm-3 control-label">执行器<font color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<select name="jobGroup" disabled class="form-control"
							id="jobGroup" th:with="type=${JobGroupList}">
							<option th:each="JobGroup : ${type}" th:text="${JobGroup.title}"
								th:value="${JobGroup.id}" th:field="*{jobGroup}">></option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">路由策略<font color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<select class="form-control" name="executorRouteStrategy"
							th:with="type=${ExecutorRouteStrategyEnum}">
							<option th:each="executorRouteStrategy : ${type}"
								th:text="${executorRouteStrategy.title}"
								th:value="${executorRouteStrategy}"
								th:field="*{executorRouteStrategy}"></option>
						</select>
					</div>
				</div>
				<!-- -->
				<div class="form-group">
					<label class="col-sm-3 control-label">运行模式<font color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<select class="form-control glueType" disabled id="glueType"
							name="glueType" th:with="type=${GlueTypeEnum}">
							<option th:each="glueType : ${type}" th:text="${glueType.desc}"
								th:value="${glueType}" th:field="*{glueType}"></option>
						</select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">任务超时时间<font
						color="black">*</font>：
					</label>
					<div class="col-sm-9">
						<input type="text" name="executorTimeout" class="form-control"
							placeholder="任务超时时间，单位秒，大于零时生效" th:field="*{executorTimeout}">
					</div>
				</div>
				<!-- <div class="form-group">
					<label class="col-sm-3 control-label">失败处理策略<font
						color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<select class="form-control" id="executorFailStrategy"
							name="executorFailStrategy"
							th:with="type=${ExecutorFailStrategyEnum}">
							<option th:each="executorFailStrategy : ${type}"
								th:text="${executorFailStrategy.title}"
								th:value="${executorFailStrategy}"
								th:field="*{executorFailStrategy}"></option>
						</select>
					</div>
				</div> -->
					<div class="form-group">
					<label class="col-sm-3 control-label">阻塞处理策略<font
						color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<select class="form-control" id="executorBlockStrategy" name="executorBlockStrategy"  th:with="type=${ExecutorBlockStrategyEnum}" >
					       <option th:each="executorBlockStrategy : ${type}" th:text="${executorBlockStrategy.title}" th:value="${executorBlockStrategy}" th:field="*{executorBlockStrategy}"></option>
				        </select>
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">负责人<font color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<input type="text" name="author" class="form-control"
							placeholder="请输入负责人" th:field="*{author}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">任务参数<font
						color="black">*</font>：
					</label>
					<div class="col-sm-9">
						<textarea name="executorParam" class="form-control"
							placeholder="请输入任务参数" th:field="*{executorParam}"></textarea>
					</div>
				</div>
			</div>

			<div class="col-md-6">
				<div class="form-group">
					<label class="col-sm-3 control-label">任务描述<font color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<input type="text" name="jobDesc" class="form-control"
							placeholder="请输入任务描述" th:field="*{jobDesc}">
					</div>
				</div>
				<div class="form-group ui-sortable-helper">
					<label class="col-sm-3 control-label">Cron<font color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<input type="text" name="jobCron" class="form-control"
							placeholder="请输入Cron" th:field="*{jobCron}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">JobHandler<font
						color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<input type="text" name="executorHandler" class="form-control"
							placeholder="请输入JobHandler" th:field="*{executorHandler}">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">子任务ID<font
						color="black">*</font>：
					</label>
					<div class="col-sm-9">
						<input type="text" name="childJobId" class="form-control"
							placeholder="请输入子任务的任务ID,如存在多个则逗号分隔" th:field="*{childJobId}">
					</div>
				</div>
				<div class="form-group ui-sortable-helper">
					<label class="col-sm-3 control-label">失败重试次数<font
						color="black">*</font>：
					</label>
					<div class="col-sm-9">
						<input type="text" name="executorFailRetryCount"
							class="form-control" th:field="*{executorFailRetryCount}"
							placeholder="失败重试次数，大于零时生效" maxlength="4">
					</div>
				</div>
				<div class="form-group">
					<label class="col-sm-3 control-label">报警邮件<font
						color="black">*</font>：
					</label>
					<div class="col-sm-9">
						<input type="text" name="alarmEmail" class="form-control"
							placeholder="请输入报警邮件，多个邮件地址则逗号分隔" th:field="*{alarmEmail}">
					</div>
				</div>
				<!-- <div class="form-group">
					<label class="col-sm-3 control-label">所属项目<font
						color="red">*</font>：
					</label>
					<div class="col-sm-9">
						<select class="form-control" id="projectId" name="projectId"  th:with="type=${@project.getProject()}">
					       <option th:each="project : ${type}" th:text="${project.projectName}" th:field="*{projectId}" th:value="${project.projectId}"></option>
				        </select>
					</div>
				</div> -->
			</div>
		</form>
	</div>
	<div th:include="include::footer"></div>
	<script type="text/javascript">
		var prefix = ctx + "job/jobinfo";
		$("#form-jobinfo-edit").validate({
			rules : {
				jobDesc : {
					required : true,
					maxlength : 50
				},
				jobCron : {
					required : true
				},
				author : {
					required : true
				},
				executorTimeout : {
					digits : true
				},
				executorTimeout : {
					digits : true
				},
				executorFailRetryCount : {
					digits : true
				}
			},
			messages : {
				jobDesc : {
					required : "请输入任务描述"
				},
				jobCron : {
					required : "请输入Cron"
				},
				author : {
					required : "请输入负责人"
				},
				executorTimeout : {
					digits : '请输入整数'
				},
				executorFailRetryCount : {
					digits : '请输入整数'
				}
			}
		});

		function submitHandler() {
			if ($.validate.form()) {
				var executorTimeout = $(
						"#form-jobinfo-edit input[name='executorTimeout']")
						.val();
				if (!/^\d+$/.test(executorTimeout)) {
					executorTimeout = 0;
				}
				$("#form-jobinfo-add input[name='executorTimeout']").val(
						executorTimeout);
				var executorFailRetryCount = $(
						"#form-jobinfo-edit input[name='executorFailRetryCount']")
						.val();
				if (!/^\d+$/.test(executorFailRetryCount)) {
					executorFailRetryCount = 0;
				}
				$("#form-jobinfo-add input[name='executorFailRetryCount']")
						.val(executorFailRetryCount);
				$.operate.save(prefix + "/edit", $('#form-jobinfo-edit')
						.serialize());
			}
		}

		function init() {
			// executorHandler
			var $executorHandler = $(".glueType").parents("form").find(
					"input[name='executorHandler']");
			var glueType = $(".glueType").val();
			if ('BEAN' != glueType) {
				$executorHandler.val("");
				$executorHandler.attr("readonly", "readonly");
			} else {
				$executorHandler.removeAttr("readonly");
			}
		}
		init();
	</script>
</body>
</html>
